package com.alibaba.nacos.controller;


import com.alibaba.nacos.service.ProviderClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class TestController {
    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private ProviderClient providerClient;

//    http://localhost:8082/consumer/{str}
//    @GetMapping("/consumer/hello/{str}")
//    public String echo(@PathVariable String str) {
//        return restTemplate.getForObject("http://service-provider/echo/{str}", String.class);
//    }

    @GetMapping("/consumer/hello")
    public String hello() {
        String providerBack = providerClient.hello();
        return "consumer1 is here." + providerBack;
    }


    /**
     * 压缩性能测试
     * @return
     */
    @GetMapping("/compress")
    public String compress() {
        return "consumer1 is here:" + providerClient.compress();
    }
}
